<?php

namespace App\Exports;

use App\model\customer\Customer;
use App\model\customer\CustomerHangye;
use App\User;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Events\AfterSheet;
use Maatwebsite\Excel\Sheet;
use phpDocumentor\Reflection\Types\Collection;
use PhpOffice\PhpSpreadsheet\NamedRange;

class CustomerExport implements FromCollection,WithEvents
{
    /**
    * @return \Illuminate\Support\Collection
    */
    public function collection()
    {
        return  collect([]);
    }
    public function registerEvents(): array
    {
        // TODO: Implement registerEvents() method.
        return [
            AfterSheet::class => function(AfterSheet $event){

                /**
                 * Adicionando Estilos
                 */

            $hangye=CustomerHangye::get(['id','name']);
            $hangyeTitle=Customer::
                /** @var Sheet $sheet */
                $sheet = $event->sheet;
                $sheet->SetCellValue( "A1", "姓名");
                $sheet->SetCellValue( "B1", "电话" );
                $sheet->SetCellValue( "C1", "位置" );
                $sheet->SetCellValue( "D1", "行业" );
                $sheet->SetCellValue( "E1", "面积" );
                $sheet->SetCellValue( "F1", "配电" );
                $sheet->SetCellValue( "G1", "需求" );
                $sheet->SetCellValue( "H1", "来源" );
                $sheet->SetCellValue( "I1", "消防" );
                $sheet->SetCellValue( "J1", "环评" );
                $sheet->SetCellValue( "K1", "描述" );
                $sheet->SetCellValue( "L1", "创建人" );


                $sheet->getParent()->addNamedRange( new NamedRange('classificacao_custo', $sheet->getDelegate(), 'BA1:BF1') );

                $event->sheet = $sheet;

            }
        ];
    }
}
